package edit;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;


public class LeafPane extends JScrollPane{
	JPanel panel;
	JLabel label; 
	JLabel wordLbl;
	JComboBox word; 
	JComboBox semCategory;
	JButton button;
	
	public LeafPane(){
		this.setBorder(BorderFactory.createTitledBorder("Select Word"));
		panel = new JPanel();  
		setViewportView(panel);
		panel.setLayout(null);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		double width = screenSize.getWidth();
		double height = screenSize.getHeight();
		int palettewidth = (int)(width*0.4);
		int paletteheight = (int)(height*0.34);
		this.setPreferredSize(new Dimension(palettewidth,paletteheight));
		addComponents();
	}
	
	private void addComponents(){
		label = new JLabel("Semantic Category: ");
		label.setBounds(5, 5, 140, 20);
		semCategory = new JComboBox();
		semCategory.setBounds(130, 5, 120, 20);
		
		wordLbl = new JLabel("Word:");
		wordLbl.setBounds(5, 30, 120, 20);
		word = new JComboBox();
		word.setBounds(130, 30, 350, 20);
		
		button = new JButton("Update");
		button.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
		JLabel blankLabel = new JLabel("");
		blankLabel.setMinimumSize(new Dimension(200,20));
		blankLabel.setMaximumSize(new Dimension(200,20));
		blankLabel.setAlignmentX(java.awt.Component.CENTER_ALIGNMENT);
		panel.add(label);
		panel.add(semCategory);
		panel.add(wordLbl);
		panel.add(word);
		panel.add(button);
		
		disableComponents();
	}
	
	public void disableComponents(){
		label.setEnabled(false);
		label.setText("Semantic Category: ");
		wordLbl.setEnabled(false);
		word.setEnabled(false);
		button.setEnabled(false);
	}
	
	public void enableComponents(){
		label.setEnabled(true);
		wordLbl.setEnabled(true);
		word.setEnabled(true);
		button.setEnabled(true);
	}
	
	public void setWordValues(){
		
	}
	
	public void setButtonListener(ActionListener actionListener){
		button.addActionListener(actionListener);
	}
	
	public void setLabelConcept(String text){
		label.setText(label.getText()+text);
	}
	
	public String getWord(){
		return word.getSelectedItem().toString();
	}
	
	
}
